<!DOCTYPE html>
<html lang="ar">
<head>
    <title>الحساب الاداري</title>
	<?php
	 define('LAST_CAPITRE_ID',19);
	 define('LAST_ARTICLE_CODE',3);
	?>

	<?php $this->load->helper('url');?>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta charset="utf-8">

<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
	<!------------------------------------------------------>
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure_imprimer.css")?>" rel="stylesheet" type="text/css" />
	
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.tablesorter.min.js');?>" ></script>
	
</head>



 



<?PHP
 $year=$this->session->userdata('annee');
$montant_consomer=0;
$today = getdate();
$date=$today['mday'].'-'.$today['mon'].'-'.$today['year'];

$total_source=0;
$total_dest=0;
for($i=0;$i<sizeof($consommer);$i++){
	$tran_s=$tran_source[$i+1];
	if($tran_s){
	$tran_so=0;	
	for($j=0;$j<sizeof($tran_s);$j++){
		$tran_so=$tran_s[$j]->montant+$tran_so;
	}
	$tab[$i]=$tran_so;
}else{
	$tab[$i]=0;
}
$total_source=$total_source+$tab[$i];
}

for($i=0;$i<sizeof($consommer);$i++){
	$tran_s=$tran_dest[$i+1];
	if($tran_s){
	$tran_so=0;	
	for($j=0;$j<sizeof($tran_s);$j++){
		$tran_so=$tran_s[$j]->montant+$tran_so;
	}
	$tab_dest[$i]=$tran_so;
}else{
	$tab_dest[$i]=0;
}
$total_dest=$total_dest+$tab_dest[$i];
}
	

$f=0;

?>

	<label>الحساب الاداري</label>
<div> من 01-01-<?php echo($year.'الى'.$date)?></div>
<br><br><br><br><br>
 <div style="width: 90%; margin-right: 5%;" class="ltr"> 
<table width="100%">		
<thead>
	<tr>
				
		<th>رصيد <br>الالتزامات</th>
		<th>الالتزامات</th>
		<th>التحويلات(+)</th>
		<th>التحويلات(-)</th>
		<th>الاعتمادات <br>المراجعة</th>
		<th>العتمادات<br> المعدلة</th>
		<th>الاعتمادات <br> المفوضة</th>
		<th>البيان</th>
		<th>البند</th>
		<th>الباب</th>
		
	</tr>
	</thead>
	<tbody>
<?php	
$init_total=0;
		$supl_total=0;
		$total_total=0;
		$consomer_total=0;
		
		
		
for($k=0;$k<sizeof($consommer);$k++){	
        
		if($budget_init_ch)$init=$budget_init_ch[$k]->solde;
		else $init=0;
		if($budget_supl_ch)$supl=$budget_supl_ch[$k]->solde;
		else $supl=0;
		$total=$init+$supl;
		$rest=$total-$consommer[$k];
		$init_total=$init_total+$init;
		$supl_total=$supl_total+$supl;
		$total_total=$total_total+$total;
		$consomer_total=$consommer[$k]+$consomer_total;
		
	
		echo('	
 
	<tr>		
		<td>'.number_format($rest, 2, ',', ' ').' </td>
		<td> '.number_format($consommer[$k], 2, ',', ' ') .'</td>
		<td>'.number_format($tab_dest[$k], 2, ',', ' ').' </td>
		<td>'.number_format($tab[$k], 2, ',', ' ').' </td>
		<td>'.number_format($total, 2, ',', ' ').' </td>
		<td>'.number_format($supl, 2, ',', ' ').' </td>
		<td> '.number_format($init, 2, ',', ' ').'</td>
		<td>'.$nom_art[$k]->nom_art.'</td>
		<td>'.$nom_art[$k]->code_art.'</td>
	    <td>'.$nom_art[$k]->code_ch.'</td>
	</tr>	
	 
			
	');	
	
	}
	
	?>	
	</tbody>
	<tfoot>	
		
     	<td>  <?php echo(number_format($total_total-$consomer_total, 2, ',', ' '))?></td>
		<td> <?php echo(number_format($consomer_total, 2, ',', ' '))?> </td>
		<td> <?php echo(number_format($total_dest, 2, ',', ' '))?></td>
		<td> <?php echo(number_format($total_source, 2, ',', ' '))?> </td>
		<td>  <?php echo(number_format($total_total, 2, ',', ' '))?></td>
		<td>  <?php echo(number_format($supl_total, 2, ',', ' '))?></td>
		<td> <?php echo(number_format($init_total, 2, ',', ' '))?> </td>
		<td colspan=3>مجموع الباب <?php echo($nom_art[0]->code_ch)?></td>

	</tfoot>
	</table>
	<br><br>
	</div>
 
  <script>
 $(document).ready(function() 
    { 
        $("#myTable").tablesorter(); 
    } 
); 
 </script>  
  <script>
$(function() {
	var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
	$( "#nom" ).autocomplete({source: liste_fourniss});
	} 
); 
</script> 

</html>